import { Message } from "./typings/index";

/**
 * 抽象出设备类，该类拥有发送消息和连接设备的抽象方法
 * 
 * @param mac 设备的mac地址
 */
export abstract class Device { 
  private _mac: string;
  constructor(mac: string) { 
    this._mac = mac;
  } 

  // 发送消息
  abstract sendMessage(message: string, device?: Device): void;
  // 接收消息
  abstract receiveMessage(_message: Message): void;

  // 虚拟方法，连接设备
  abstract linkDevice(device: Device): void;

  get mac(): string { 
    return this._mac;
  }
}
